<template>
  <tpl-address-info ref="addressInfos"/>
</template>

<script>
import tplAddressInfo from '../components/tplAddressInfo'
export default {
  name: 'Index',
  components: {
    tplAddressInfo
  },
  mounted() {
    this.getEditData()
  },
  methods: {
    getEditData() {
      const route = this.$route
      const address = JSON.parse(route.query.address)
      const addressForm = this.$refs.addressInfos.addressForm
      addressForm.name = address.name
      addressForm.province_id = address.address_province_id
      addressForm.city_id = address.address_city_id
      addressForm.area_id = address.address_area_id
      addressForm.address_name = address.address_name
      addressForm.address_mobile = address.address_mobile
      addressForm.address_tel = address.address_tel
      addressForm.address_detail = address.address_detail
      addressForm.is_default = address.is_default
      addressForm.user_address_id = address.user_address_id
      this.$refs.addressInfos.addressForm = addressForm
      // this.$refs.addressInfos.$refs.selectAddress.province_id = '河北省'
      // this.$refs.addressInfos.$refs.selectAddress.city_id = '石家庄市'
      // this.$refs.addressInfos.$refs.selectAddress.area_id = '长安区'
      const stringArr = address.address_address.split(' ')
      stringArr.splice(stringArr.length - 1, 1)
      const result = stringArr.toString()
      const newStr = result.replace(',', ' ')
      this.$refs.addressInfos.$refs.selectAddress.addressInfo = newStr
    }
  }
}
</script>

<style scoped>

</style>
